<template>
  <div>
    <h1>站点管理</h1>
    <el-form :inline="true" :model="condition" class="demo-form-inline" :row-class-name="tableRowClassName">
      <el-form-item label="站点编号">
        <el-input v-model="condition.id" placeholder="请输入站点编号" />
      </el-form-item>
      <el-form-item label="服务站点名">
        <el-select v-model="condition.nickname" placeholder="请输入服务站点">
          <el-option label="浆洗街道服务站" value="shanghai" />
          <el-option label="肖家河服务站" value="beij" />
          <el-option label="红牌楼服务站" value="beijin" />
          <el-option label="高升桥服务站" value="be" />
          <el-option label="衣冠庙服务站" value="beijing" />
        </el-select>
      </el-form-item>
      <div class="m-4">
        <span>区域&emsp;</span>
        <el-cascader v-model="value" :options="options" @change="handleChange" />
        <el-form-item>
          &emsp;
          <el-button class="query" type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
      </div>
    </el-form>

    <!-- //表格 -->
    <el-table :data="arr" v-model="number.id" style="width:100%" >
      <el-table-column prop="number"  v-for="todo in number.id" label="编号" width="200">{{ number.id }}</el-table-column>
      <el-table-column prop="name" label="站名" width="350"></el-table-column>
      <el-table-column prop="address" label="服务站地址" width="300"></el-table-column>
      <el-table-column prop="time" label="服务时间" width="200">{{ time }}</el-table-column>
      <el-table-column prop="phone" label="联系电话" width="200"></el-table-column>
      <el-table-column prop="address" label="查看地址" width="200"></el-table-column>
      
      <el-table-column label="操作" width="200">
        <template #default="scope">
          <el-button type="primary" text @click="editopen">编辑</el-button>
          <el-button type="danger" @click="Remove(scope.row._id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background layout="total, ->, prev, pager, next, sizes, jumper" :total="10" />
    <!-- <el-dialog v-model="editopen" title="编辑会员"> -->
    <!-- 渲染编辑会员表单 -->
    <Modal v-model="editopen" ref="editUserRef" v-show="isHandle">
      <template #header>
        <h1>信息编辑</h1>
      </template>
      <template #man>
        <div class="middle-spanbox">
          <span>&emsp;站名：</span><input style="width: 500px;:any;
             border-top: 0;
              border-left: 0;
              border-right: 0; " type="text" placeholder="请输入服务站名称">
        </div>
        <div class="middle-spanbox">
          <span>&emsp;地址：</span><input style="width: 500px;
             border-top: 0;
              border-left: 0;
              border-right: 0; " type="text" placeholder="请输入地址">
        </div>
        <div class="middle-spanbox">
          <span>&emsp;联系电话：</span><input style="width: 456px;
             border-top: 0;
              border-left: 0;
              border-right: 0; " type="text" placeholder="请输入服务站名称">
        </div>


      </template>
      <template #footer>
        <el-popconfirm title="确认修改当前内容吗?">
          <template #reference>
            <el-button @click="isShow" 
            style="display: block; 
            width: 100px;
             margin-left: 600px;
             height: 40px;
             font-size: 24px;
             margin-top: 20px;
             ">确认</el-button>
          </template>
        </el-popconfirm>
      </template>


    </Modal>
    <!-- <template #footer>
        <span class="dialog-footer">
          <el-button @click="editopen = false">取消</el-button>
          <el-button type="primary" @click="handleSave">
            保存
          </el-button>
        </span>
      </template>
    </el-dialog> -->
  </div>
</template>

<script>
import { service } from '../../api/member'
import Modal from './modal.vue' 	// 展示展示展示展示展示展示展示展示展示展


export default {
  name: 'Usersite',
  components: {
    Modal // 局部注册编辑会员组件
  },

  data() {
    return {
      number:[
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
        {id:'1'},
    ],
      condition: {},
      props: [
      ],
      arr: [],
      time: '上午9:00-12:00  下午14:00-18:00',
      // editopen: false,
      isHandle: false,
    }
  },

  methods: {
    // arr2() {
    //   this.number.map(item,index){
    //     this.number[id]==index
    //   }
    // },

    open() {
      ElMessageBox.prompt('Please input your e-mail', 'Tip', {
        confirmButtonText: 'OK',
        cancelButtonText: 'Cancel',

        inputErrorMessage: 'Invalid Email',
      })
        .then(({ value }) => {
          ElMessage({
            type: 'success',
            message: `Your email is:${value}`,
          })
        })
        .catch(() => {
          ElMessage({
            type: 'info',
            message: 'Input canceled',
          })
        })
    },
    editopen() {
      this.isHandle = true
    },
    isShow(){
      this.isHandle = false
    }
  },

  // created() {
  //   this.findMembers()
  // },



  // async editText(id) {
  //   console.log(id)
  //   try{
  //     await({})
  //   }
  // },

  async mounted() {
    const result = await service()
      .then(res => {
        console.log(res)
        return this.arr = res.list
      }).catch(err => console.log(err))  // 这里显示的都是响应式类型的错误处理，但是在展示中将其与请求失败的情况相同。 不要忘记在你的页面中引入

  },
  async Remove(id) {
    console.log(id)
    try {
      await ElMessageBox.confirm(
        '确认删除当前医生信息吗?',
        '删 除',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
          center: true,
        }
      )

      // 确认删除
      await delMembers(id)
      // 删除成功。重新渲染
      this.findMembers({ page: this.page, pageSize: this.pageSize })
    } catch (error) {
      console.log(error)
    }
  },
}

</script>

<style lang="less">
.m-4 {
  line-height: 2.5rem;

  span {
    color: rgb(90, 87, 82);
    font-size: .8rem;
  }

  .query {
    margin-top: 1.1rem;
  }

  .el-table-column {
    text-align: center;
  }
}
.el-table .cell {
  text-align: center;
}

</style>
